package test.noah.chery.controllers;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import test.noah.chery.entity.City;
import test.noah.chery.entity.Country;
import test.noah.chery.entity.Countrylanguage;
import test.noah.chery.service.CountryCityService;


@Controller
public class CountryCityController {
	
	private final static Logger logger = Logger.getLogger(CountryCityController.class);
	
	
	@Autowired
	private CountryCityService countrycityservice;
	
	@RequestMapping(value="/ShowCountryCity" , method = RequestMethod.GET)
	public String show(){
		return "ShowCountryCity";
		
	}
	
	@RequestMapping(value="/ShowCountryCity.htm" , method = RequestMethod.POST)
	public @ResponseBody List<List<?>> seleByCountryCity(){
		List<List<?>> list =new ArrayList<List<?>>();
		List<Country> countrylist = new ArrayList<Country>();
		countrylist = countrycityservice.selectByCountry(new Country());
		list.add(countrylist);
		logger.info("add country success....");
		List<City> citylist = new ArrayList<City>();
		citylist = countrycityservice.selectByCity(new City());
		list.add(citylist);
		logger.info("add city success...");
		List<Countrylanguage> languagelist = new ArrayList<Countrylanguage>();
		languagelist = countrycityservice.selectByCountrylanguage(new Countrylanguage());
		list.add(languagelist);
		logger.info("add language success...");
		return list;
	}
	
	
}
